package com.day21.test3;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.SQLException;

public class util {

    public static DruidPooledConnection getConnection(){
        ApplicationContext a=new ClassPathXmlApplicationContext("day21test3.xml");

        DruidDataSource d=a.getBean("dataSource",DruidDataSource.class);

        try {
            DruidPooledConnection con=d.getConnection();

            return con;

        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
